using Gameplay.PVE.Entity;
using UnityEngine;
using UnityEngine.AI;
using Yoozoo.Libs;

namespace Gameplay.PVE
{
    public class ObstacleComponent : IComponent
    {
        private UnitBase unit;
        private NavMeshObstacle obstacle;
        
        void IClass.OnReset()
        {
            
        }
        
        void IComponent.OnInitialize(UnitBase unit)
        {
            this.unit = unit;
        }

        void IComponent.OnBirth()
        {
            obstacle = unit.gameObject.GetOrAddComponent<NavMeshObstacle>();
            obstacle.enabled = true;
            obstacle.shape = NavMeshObstacleShape.Box;
            obstacle.carving = true;
            obstacle.size = unit.Data.colliderSize;
            obstacle.center = unit.Data.colliderCenter;
        }

        void IComponent.OnDead()
        {
            obstacle.enabled = false;
        }

        void IComponent.OnUpdate()
        {
            
        }
    }
}